package cn.fl.ref.fncprjbscinfo.transform;

import java.util.ArrayList;
import java.util.List;

import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.ref.fncprjbscinfo.vo.FncPrjSplitAccountVO;
import fl.ref.fncprjbscinfo.dto.FncPrjSplitAccountDTO;

/**
 * 服务层与展现层转换类
 * 所有的PO只能在持久成和服务层使用
 * 所有的DTO只能在展现层和服务层使用
 * 在服务层中向下是DTO转PO,向上是PO转DTO
 */
public class FncPrjSplitAccountVOTransform {

	/**
	 * VO 转  DTO
	 * @param po
	 * @return
	 */
	public static FncPrjSplitAccountDTO toDTO(FncPrjSplitAccountVO vo) {
		FncPrjSplitAccountDTO  dto = null;
		if (vo != null) { 
			dto = new FncPrjSplitAccountDTO();
			dto.setId(vo.getId());
			dto.setFncprjid(vo.getFncprjid()); //FNC_PRJ_BSC_INFO.ID
            dto.setSplitAccount(vo.getSplitAccount());// 分账账户
        	if(null == vo.getSplitRatio()) {
        	}else {
        		 dto.setSplitRatio(vo.getSplitRatio());//分账比例	
        	}
        	dto.setPayMay(vo.getPayMay());//支付通道
        	dto.setCrtTm(vo.getCrtTm());
        	dto.setCrtUsrId(vo.getCrtUsrId());
        	dto.setMdfTm(vo.getMdfTm());
        	dto.setMdfUsrId(vo.getMdfUsrId());
        	dto.setIsdel(vo.getIsdel());
        	dto.setIsvalid(vo.getIsvalid());
        	dto.setFundInsNm(vo.getFundInsNm());
        	dto.setFundInsId(vo.getFundInsId());
        	dto.setInsCode(vo.getInsCode());
        	dto.setMainAccountId(vo.getMainAccountId());//主账户id
		}
		return dto;
	}

	/**
	 * DTO 转  PO
	 * @param dto
	 * @return
	 */
	public static FncPrjSplitAccountVO toVO(FncPrjSplitAccountDTO dto) {
		FncPrjSplitAccountVO vo = null;
		if (dto != null) {
			vo = new FncPrjSplitAccountVO();
			vo.setId(dto.getId());
			vo.setFncprjid(dto.getFncprjid()); //FNC_PRJ_BSC_INFO.ID
			vo.setSplitAccount(dto.getSplitAccount());// 分账账户
			if(null == dto.getSplitRatio()) {
			}else {
				vo.setSplitRatio(dto.getSplitRatio());//分账比例
			}
			
			vo.setPayMay(dto.getPayMay());//支付通道
			vo.setCrtTm(dto.getCrtTm());
			vo.setCrtUsrId(dto.getCrtUsrId());
			vo.setMdfTm(dto.getMdfTm());
			vo.setMdfUsrId(dto.getMdfUsrId());
			vo.setIsdel(dto.getIsdel());
			vo.setIsvalid(dto.getIsvalid());
			vo.setFundInsNm(dto.getFundInsNm());
			vo.setFundInsId(dto.getFundInsId());
			vo.setInsCode(dto.getInsCode());
			vo.setMainAccountId(dto.getMainAccountId());//主账户id
			vo.setIsBack(dto.getIsBack());//是否存在备用通道   是   否
		}
		return vo;
	}
	
	/**
	 * PO集合 转 DTO集合
	 * @param list
	 * @return
	 */
	public static List<FncPrjSplitAccountDTO> toDTOList(List<FncPrjSplitAccountVO> list) {
		List<FncPrjSplitAccountDTO>  voList = new ArrayList<FncPrjSplitAccountDTO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (FncPrjSplitAccountVO vo : list) {
				voList.add(toDTO(vo));
			}
		}
		return voList;
	}
	
	/**
	 * DTO集合 转 PO集合
	 * @param list
	 * @return
	 */
	public static List<FncPrjSplitAccountVO> toVOList(List<FncPrjSplitAccountDTO> list) {
		List<FncPrjSplitAccountVO>  voList = new ArrayList<FncPrjSplitAccountVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (FncPrjSplitAccountDTO dto : list) {
				voList.add(toVO(dto));
			}
		}
		return voList;
	}
	
}
